<?php
/**
 * Created by PhpStorm.
 * User: Dave
 * Date: 2018/6/19
 * Time: 15:30
 */

namespace Biz\tools;

use Doraemon\pockets\config\IniConfig;

class SensorsApi
{
    const  CONFIG_FILE_ = 'sensorsdata';

    public static function getCourierBirdConfig($way)
    {
        return IniConfig::getConfigSelect(static::CONFIG_FILE_,$way);
    }

    public static  function clicks($event, $type, $field, $where, $sensorsdataConf)
    {
        $o = new SensorsApiModel($sensorsdataConf['host'].':'.$sensorsdataConf['port'] , $sensorsdataConf['token'] , $sensorsdataConf['project']);
        $oFilter = new SensorsApiFilter($event);
        $oFilter->addEqualFilter("type",$type);
        $oFilter->addEqualFilter($field , $where);
        $count = $o->init_query($event )
            ->setFilter($oFilter)
            ->setDateRange('2018-04-01')
            ->get_total_bydate();

        $oFilter->removeFilter();
        return $count;
    }
}